package com.kws.merchant.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kws.merchant.domain.Device;
import com.kws.merchant.domain.Serve;
import com.kws.merchant.domain.po.RemarkPo;
import com.kws.merchant.domain.po.ServePo;
import com.kws.merchant.domain.po.StatusCheck;
import com.kws.merchant.domain.vo.ServeVo;
import com.kws.merchant.service.ServeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import com.kws.common.core.domain.R;

import javax.annotation.Resource;
import java.util.List;

/**
 * 商品-服务(Serve)表控制层
 *
 * @author yxy
 * @since 2024-10-22 15:57:33
 */
@RestController
@Api(tags = "服务(Serve)")
@RequestMapping("serve")
public class ServeController {
    /**
     * 服务对象
     */
    @Resource
    private ServeService serveService;

    @PostMapping("/page")
    @ApiOperation(value = "分页查询列表")
    public R<Page<Serve>> pageList(@RequestBody ServePo serve) {
        return R.ok(serveService.pageList(serve));
    }

    @GetMapping("/detailById/{id}")
    @ApiOperation(value = "商品服务详情")
    public R<ServeVo> detailById(@PathVariable Long id) {
        return R.ok(serveService.detailById(id));
    }


    @PostMapping("/addServe")
    @ApiOperation(value = "新增服务")
    public R add(@RequestBody Serve serve) {
        return R.ok(serveService.addServe(serve));
    }

    @PostMapping("/updateServe")
    @ApiOperation(value = "修改商品服务")
    public R updateServe(@RequestBody Serve serve) {
        return R.ok(serveService.updateServe(serve));
    }


    @PostMapping("/delete")
    @ApiOperation(value = "删除数据-可删除多个")
    public R removeByIdList(@RequestBody List<Long> idList) {
        return R.ok(serveService.removeByIdList(idList));
    }

    @PostMapping("/updateStatus")
    @ApiOperation(value = "商品服务上下架")
    public R updateStatus(@RequestBody StatusCheck statusCheck) {
        return R.ok(serveService.updateStatus(statusCheck));
    }

    @PostMapping("serveRemark")
    @ApiOperation("新增商品服务评论")
    public R serveRemark(@RequestBody RemarkPo remarkPo ){
        return R.ok(serveService.serveRemark(remarkPo));
    }

    @PostMapping("/repealCheck/{id}")
    @ApiOperation(value = "撤销审核")
    public R repealCheck(@PathVariable Long id) {
        return R.ok(serveService.repealCheck(id));
    }

    @GetMapping("/listByMerchant")
    @ApiOperation(value = "商家服务列表")
    public R<List<Serve>> listByMerchant() {
        return R.ok(serveService.listByMerchant());
    }
}
